package fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.example.admintor.humaninteraction.Data;
import com.example.admintor.humaninteraction.LoginActivity;
import com.example.admintor.humaninteraction.R;

import java.lang.reflect.Field;

/**
 * 迎宾控制
 * Created by Admintor on 2017/11/9.
 */

public class TwoFragment extends Fragment implements View.OnClickListener {
    ImageView icon;
    Button btn;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.activity_two, container, false);
        FindView(view);
        return view;
    }

    @Override
    public void onDetach() {
        super.onDetach();
        try {
            Field childFragmentManager = Fragment.class.getDeclaredField("mChildFragmentManager");
            childFragmentManager.setAccessible(true);
            childFragmentManager.set(this, null);
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }

    private void FindView(View view) {
        icon = (ImageView) view.findViewById(R.id.icon);
        btn = (Button) view.findViewById(R.id.btn);
        btn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn:
                LoginActivity.landing.setKeyByUiid(Data.MEN_LING, 1);
                break;
        }
    }
}
